export default function(){
    function login(){

    }
    $.extend(login.prototype,{
        init : function(){
            this.btn = $(".btn");
            this.btn.on("click" , "input" , $.proxy(this.login,this));
        },
        login : function(){
            var username = $("#account").val();
            var password = $("#inter_code").val();
            if(username == "" || password ==""){
                alert("账号或密码不能为空");
            }
            else{
                var ls = localStorage.getItem("user");
                if(ls === null){
                    if(window.confirm("该用户不存在，请先注册")){
                        location.href = "http://localhost/VSCode/JuanPi_web_project/src/register.html"
                    }
                }
                else{
                    var la = JSON.parse(ls);
                    $.each(la,function(index,item){
                        if(item.user_phone === username && item.user_pwd === password){
                            alert("登录成功");
                            location.href = "http://localhost/VSCode/JuanPi_web_project/src/index.html"
                        }
                        else{
                            alert("账号或密码错误");
                        }     
                    })
                }
                
            }
        }
    })
    return new login();
}